home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / CBTSAMP.PAK / CUSTOMER.MNU < prev    next >
Text File  |  1995-07-18  |  9KB  |  259 lines

  1. ******************************************************************************
  2. *  PROGRAM:      Customer.mnu
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         12/93
  7. *
  8. *  UPDATED:      6/95
  9. *
  10. *  REVISION:     $Revision:   1.55  $
  11. *
  12. *  VERSION:      Visual dBASE
  13. *
  14. *  DESCRIPTION:  This menu file is used by Customer.wfm for performing simple
  15. *                tasks.  It allows adding, deleting, and searching for
  16. *                customers, brings up the orders form for a customer,
  17. *                and runs reports.
  18. *
  19. *  PARAMETERS:   FormObj -- the form to which this menu is attached.
  20. *
  21. *  CALLS:        None
  22. *
  23. *  USAGE:        form.menuFile = "Customer.mnu"
  24. *
  25. *******************************************************************************
  26. #include <Messdlg.h>
  27.  
  28. ** END HEADER -- do not remove this line*
  29. * Generated on 06/21/94
  30. *
  31. Parameter FormObj
  32. NEW CUSTOMERMENU(FormObj,"Root")
  33. CLASS CUSTOMERMENU(FormObj,Name) OF MENUBAR(FormObj,Name)
  34.    this.Text = ""
  35.    this.OnInit = {;set procedure to &_dbwinhome.samples\Sampproc.prg}
  36.  
  37.    DEFINE MENU FILE OF THIS;
  38.        PROPERTY;
  39.          Text "&File"
  40.  
  41.          DEFINE MENU EXIT OF THIS.FILE;
  42.              PROPERTY;
  43.                OnClick CLASS::ONEXIT,;
  44.                Text "E&xit",;
  45.                StatusMessage "Leave Customer form."
  46.  
  47.    DEFINE MENU CUSTOMER OF THIS;
  48.        PROPERTY;
  49.          Text "&Customer"
  50.  
  51.          DEFINE MENU VIEWEDIT OF THIS.CUSTOMER;
  52.              PROPERTY;
  53.                OnClick CLASS::VIEWEDITONCLICK,;
  54.                Text "&Edit",;
  55.                Shortcut "Ctrl-E",;
  56.                StatusMessage "Edit data."
  57.  
  58.          DEFINE MENU SEPARATOR1 OF THIS.CUSTOMER;
  59.              PROPERTY;
  60.                Separator .T.,;
  61.                Text ""
  62.  
  63.          DEFINE MENU ADD OF THIS.CUSTOMER;
  64.              PROPERTY;
  65.                OnClick CLASS::ADDONCLICK,;
  66.                Text "&Add",;
  67.                Shortcut "Ctrl-A",;
  68.                Enabled .T.,;
  69.                StatusMessage "Add a new customer."
  70.  
  71.          DEFINE MENU DELETE OF THIS.CUSTOMER;
  72.              PROPERTY;
  73.                OnClick CLASS::DELETEONCLICK,;
  74.                Text "&Delete",;
  75.                Shortcut "Ctrl-D",;
  76.                Enabled .F.,;
  77.                StatusMessage "Delete the current customer."
  78.  
  79.          DEFINE MENU SEPARATOR2 OF THIS.CUSTOMER;
  80.              PROPERTY;
  81.                Separator .T.,;
  82.                Text ""
  83.  
  84.          DEFINE MENU SEARCH OF THIS.CUSTOMER;
  85.              PROPERTY;
  86.                OnClick CLASS::SEARCHONCLICK,;
  87.                Text "&Search ...",;
  88.                Shortcut "Ctrl-S",;
  89.                StatusMessage "Search for a customer."
  90.  
  91.          DEFINE MENU SEPARATOR3 OF THIS.CUSTOMER;
  92.              PROPERTY;
  93.                Separator .T.,;
  94.                Text ""
  95.  
  96.          DEFINE MENU CURRENT_ORDERS OF THIS.CUSTOMER;
  97.              PROPERTY;
  98.                OnClick CLASS::CURRENTORDERSONCLICK,;
  99.                Text "&Orders ...",;
  100.                Shortcut "Ctrl-O",;
  101.                StatusMessage "See the orders for the current customer in the Orders form."
  102.  
  103.    DEFINE MENU REPORT OF THIS;
  104.        PROPERTY;
  105.          Text "&Report"
  106.  
  107.          DEFINE MENU CUSTOMER_REPORT OF THIS.REPORT;
  108.              PROPERTY;
  109.                OnClick {;create session ;set lock off ;report form customer},;
  110.                Text "Customer &Report",;
  111.                Shortcut "Ctrl-R",;
  112.                StatusMessage "Display a report of customer information."
  113.  
  114.          DEFINE MENU CUSTOMER_LABELS OF THIS.REPORT;
  115.              PROPERTY;
  116.                OnClick {;create session ;set lock off ;report form customer.rpl},;
  117.                Text "Customer &Labels",;
  118.                Shortcut "Ctrl-L",;
  119.                StatusMessage "Display labels for all customers."
  120.  
  121.  
  122.    ****************************************************************************
  123.    procedure SearchOnClick
  124.  
  125.    * Bring up Search.wfm modally.
  126.    ****************************************************************************
  127.    private searchForm, searchItem, saveRec
  128.  
  129.    if reccount() = 0                    && If table is empty, don't search
  130.       InformationMessage("This table is empty.", "Oops")
  131.    else
  132.       form.CheckChanged(.T.)
  133.       set procedure to &_dbwinhome.samples\Search.wfm additive
  134.       searchForm = new SearchForm()
  135.       searchForm.keyName = "Name"       && Indicate to user expression to enter
  136.       searchForm.formatting = "@X"
  137.       searchForm.mdi = .F.              && Necessary for a modal form
  138.       searchItem = searchForm.Readmodal()
  139.       if type("searchItem") = "O" .and. searchItem.id <> 0;
  140.                                   .and. .not. empty(searchForm.value)
  141.          *** If Cancel or ESC wasn't used to exit Search.wfm
  142.          saveRec = recno()
  143.          form.enabled = .F.
  144.          seek upper(ltrim(rtrim(searchForm.value)))
  145.          if .not. found()
  146.             InformationMessage(FormatStr("Customer %1 \n Was not Found.",;
  147.                                          searchForm.value),;
  148.                                "Info")
  149.             if saveRec <= reccount()    && If weren't at eof(), go to saveRec
  150.                go saveRec
  151.             else
  152.                go bottom
  153.             endif
  154.          endif
  155.          form.enabled = .T.
  156.       endif
  157.  
  158.       searchForm.Release()
  159.       close procedure &_dbwinhome.samples\Search.wfm
  160.    endif
  161.  
  162.  
  163.    ****************************************************************************
  164.    procedure DeleteOnClick
  165.  
  166.    * Delete current record.
  167.    ****************************************************************************
  168.  
  169.    if ConfirmationMessage("Are you sure you want to delete this customer?",;
  170.                              "Confirm") = YES
  171.       delete  && Deleted is on, so deleted records are there until you PACK
  172.       commit()
  173.       form.changesMade = .F.
  174.       begintrans()
  175.       if type("form.nextCustButton") <> "U"
  176.          form.nextCustButton.OnClick()  && Move to next record (customer.wfm)
  177.       else
  178.          form.vcrNextButton.OnClick()   && Move to next record (custord.wfm)
  179.       endif
  180.    endif
  181.  
  182.  
  183.    ****************************************************************************
  184.    procedure AddOnClick
  185.  
  186.    * Add new record.
  187.    ****************************************************************************
  188.    private addForm, custNoField, newCustomer, inEditMode
  189.  
  190.    form.CheckChanged(.T.)
  191.    if ConfirmationMessage("Are you sure you want to add a customer?",;
  192.                              "Confirmation") = YES
  193.       * If running from Custord.wfm, use form.curPage.inEditMode,
  194.       * otherwise, if from customer.wfm/orders.wfm, use form.inEditMode
  195.       inEditMode = iif(type("form.curPage") <> "U", form.curPage.inEditMode,;
  196.                                                     form.inEditMode)
  197.       if .not. inEditMode
  198.          form.ViewEdit()                 && Make sure record is editable
  199.       else
  200.          form.nameEntry.SetFocus()
  201.       endif                              && and begin a transaction
  202.       form.changesMade = .T.             && Since we are adding a record
  203.       form.previousRecord = recno()
  204.       append blank                       && This must be done after begintrans()
  205.       custNoField = field(1)             && so rollback() could delete if necessary
  206.       newCustomer = str(val(form.maxCustNo) + 1, 4)
  207.       replace &custNoField with newCustomer     && New customer number
  208.       form.maxCustNo = newCustomer
  209.    endif
  210.  
  211.  
  212.    ****************************************************************************
  213.    procedure CurrentOrdersOnclick
  214.  
  215.    * Show orders for current customer by bringing up Orders.wfm
  216.    ****************************************************************************
  217.  
  218.    form.CheckChanged(.T.)
  219.    if type ("form.parentOrdersForm") = "U"
  220.       if type ("form.childOrdersForm") = "U"
  221.          form.StartOrdersForm()
  222.          form.CallShowOrders(customer->customer_n)
  223.       else
  224.          form.CallShowOrders(customer->customer_n)
  225.          form.childOrdersForm.open()
  226.          form.childOrdersForm.windowState = 0
  227.          form.childOrdersForm.windowState = 0
  228.          form.childOrdersForm.setFocus()
  229.       endif
  230.    else
  231.       form.parentOrdersForm.setFocus()
  232.    endif
  233.  
  234.  
  235.    ****************************************************************************
  236.    procedure ViewEditOnClick
  237.  
  238.    * Toggle View/Edit modes.
  239.    ****************************************************************************
  240.  
  241.    form.ViewEdit()
  242.  
  243.  
  244.    ****************************************************************************
  245.    procedure OnExit
  246.  
  247.    * Clean up.
  248.    ****************************************************************************
  249.  
  250.    if type ("form.parentOrdersForm") <> "U"
  251.       * Release parent orders form, which releases this child
  252.       form.parentOrdersForm.Release()
  253.    else
  254.       form.Release()
  255.    endif
  256.  
  257.  
  258. ENDCLASS
  259.